<cfcomponent extends="assets.calgrants.com.Base">

	<cffunction name="get" output="false" access="remote" returntype="array">
		<!--- <cfargument name="Survey_ID" type="numeric" required="no" /> --->
		<cfargument name="Survey_Type" type="string" default="" required="no" />
		<cfargument name="Program_Year" type="string" required="no" default="#request.currentProgramYear#" />
		<cfset var survey = "" />
		<cfset var sArray = ArrayNew(1) />
		<cfset var qStruct = "" />
		<cfset var aStruct = "" />
		<cfstoredproc datasource="#getDatasource()#" procedure="getSurvey">
				<!--- <cfprocparam value="#arguments.Survey_ID#" cfsqltype="cf_sql_integer" null="#IIf(Len(Trim(arguments.Survey_ID)) gt 0, false, true)#" /> --->
				<cfprocparam value="#arguments.Survey_Type#" cfsqltype="cf_sql_varchar" null="#IIf(Len(Trim(arguments.Survey_Type)) gt 0, false, true)#" />
				<cfprocparam value="#arguments.Program_Year#" cfsqltype="cf_sql_varchar" null="#IIf(Len(Trim(arguments.Program_Year)) gt 0, false, true)#" />
			<cfprocresult name="survey" />
		</cfstoredproc>
		<cfoutput query="survey" group="Question_Number">
			<cfif Question_Active eq 1>
				<cfset qStruct = StructNew() />
				<cfset qStruct.Question_ID = Question_ID />
				<cfset qStruct.Question_Field = Question_Field />
				<cfset qStruct.Question_Active = Question_Active />
				<cfset qStruct.Question_Required = Question_Required />
				<cfset qStruct.Question_Type = Question_Type />
				<cfset qStruct.Question_Number = Question_Number />
				<cfset qStruct.Question = Question />
				
				<cfset qStruct.Response_Count = 0 />
				<cfset qStruct.No_Response_Count = 0 />
				<cfset qStruct.Multi_Response_Count = 0 />
				
				<cfset qStruct.Senior_Response_Count = 0 />
				<cfset qStruct.Senior_No_Response_Count = 0 />
				<cfset qStruct.Senior_Multi_Response_Count = 0 />
				
				<cfset qStruct.Answers = ArrayNew(1) />
				<cfoutput>
					<cfif Answer_Active eq 1>
						<cfset aStruct = StructNew() />
						<cfset aStruct.Answer_ID = Answer_ID />
						<cfset aStruct.Answer_Active = Answer_Active />
						<cfset aStruct.Answer_Number = Answer_Number />
						<cfset aStruct.Answer = Answer />
						<cfset aStruct.Answer_Type = Answer_Type />
						<cfset aStruct.Answer_Value = Answer_Value />
						<cfset aStruct.Answer_Values = ArrayNew(1) />
						<cfset aStruct.Response_Count = 0 />
						<cfset aStruct.Response_Percent = 0 />
						<cfset ArrayAppend(qStruct.Answers, aStruct) />
					</cfif>
				</cfoutput>
				<cfset ArrayAppend(sArray, qStruct) />
			</cfif>
		</cfoutput>
		<cfreturn sArray />
	</cffunction>

</cfcomponent>